package com.anolesoft.amljmes.test.fenguangyingdu.mapper;

import com.anolesoft.amljmes.test.fenguangyingdu.entity.FenguangYingduRecordLogQueryDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.LocalDateTimeTypeHandler;

import java.util.List;

/**
 * @author zhj
 * @date 2021/12/22 10:32
 */
@Mapper
public interface FenguangYingduRecordLogQueryMapper {
    @Results(id = "FenguangYingduRecordLogQueryResultMap", value = {
            @Result(id = true, column = "objuid", property = "objuid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianbiaotiaoma", property = "jianbiaotiaoma", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jixing", property = "jixing", jdbcType = JdbcType.VARCHAR),
            @Result(column = "tuhao", property = "tuhao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "cailiaopaihao", property = "cailiaopaihao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "songjiandanwei", property = "songjiandanwei", jdbcType = JdbcType.VARCHAR),
            @Result(column = "lupihao", property = "lupihao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianshu", property = "jianshu", jdbcType = JdbcType.INTEGER),
            @Result(column = "songjiangongxuhao", property = "songjiangongxuhao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "songjiangongxumingcheng", property = "songjiangongxumingcheng", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fenguangshuliang", property = "fenguangshuliang", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushuliang", property = "yingdushuliang", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushicezhi", property = "yingdushicezhi", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianyan", property = "jianyan", jdbcType = JdbcType.VARCHAR),
            @Result(column = "beizhu", property = "beizhu", jdbcType = JdbcType.VARCHAR),
            @Result(column = "state", property = "state", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_user", property = "createUser", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_date", property = "createDate", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "shenpiren", property = "shenpiren", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpishijian", property = "shenpishijian", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "zhizaojilutiaoma", property = "zhizaojilutiaoma", jdbcType = JdbcType.VARCHAR),
            @Result(column = "zhizaojiluid", property = "zhizaojiluid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqingren", property = "shenqingren", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqingshijian", property = "shenqingshijian", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "record_id", property = "recordId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fenguangshuliang_new", property = "fenguangshuliangNew", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushuliang_new", property = "yingdushuliangNew", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushicezhi_new", property = "yingdushicezhiNew", jdbcType = JdbcType.VARCHAR),
            @Result(column = "xiuggairen", property = "xiuggairen", jdbcType = JdbcType.VARCHAR),
            @Result(column = "xiuggaishijian", property = "xiuggaishijian", typeHandler = LocalDateTimeTypeHandler.class),

            @Result(column = "create_user_eid", property = "createUserEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_user_name", property = "createUserName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpi_eid", property = "shenpiEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpi_name", property = "shenpiName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqing_eid", property = "shenqingEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqing_name", property = "shenqingName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "xiugairen_eid", property = "xiugairenEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "xiugairen_name", property = "xiugairenName", jdbcType = JdbcType.VARCHAR),
    })
//    private Integer fenguangshuliangNew;
//    private Integer yingdushuliangNew;
//    private String yingdushicezhiNew;
//    private String beizhuNew;
//    private String xiuggairen;
//    private LocalDateTime xiuggaishijian;
    @Select("<script>" +
            "SELECT\n" +
            "a.OBJUID,\n" +
            "a.JIANBIAOTIAOMA,\n" +
            "a.TUHAO,\n" +
            "a.JIXING,\n" +
            "a.CAILIAOPAIHAO,\n" +
            "a.SONGJIANDANWEI,\n" +
            "a.LUPIHAO,\n" +
            "a.JIANSHU,\n" +
            "a.SONGJIANGONGXUHAO,\n" +
            "a.SONGJIANGONGXUMINGCHENG,\n" +
            "a.FENGUANGSHULIANG,\n" +
            "a.YINGDUSHULIANG,\n" +
            "a.YINGDUSHICEZHI,\n" +
            "a.JIANYAN,\n" +
            "a.BEIZHU,\n" +
            "a.STATE,\n" +
            "a.CREATE_USER,\n" +
            "a.CREATE_DATE,\n" +
            "a.MODIFY_USER,\n" +
            "a.MODIFY_DATE,\n" +
            "a.SHENPIREN,\n" +
            "a.SHENPISHIJIAN,\n" +
            "a.ZHIZAOJILUTIAOMA,\n" +
            "a.ZHIZAOJILUID,\n" +
            "a.SHENQINGREN,\n"+
            "a.SHENQINGSHIJIAN,\n"+
            "a.XIUGGAIREN,\n"+
            "a.XIUGGAISHIJIAN,\n"+
            "b.EMP_ID create_user_eid,\n" +
            "b.EMP_NAME create_user_name,\n" +
            "c.EMP_ID shenpi_eid,\n" +
            "c.EMP_NAME shenpi_name, \n" +
            "d.EMP_ID shenqing_eid,\n" +
            "d.EMP_NAME shengqing_name, \n" +
            "e.EMP_ID xiugairen_eid,\n" +
            "e.EMP_NAME xiugairen_name \n" +
            "FROM \n" +
            "CHECK_FENGUANGYINGDU_RECORDLOG a \n" +
            "left join FAC_EMPLOYEE b on a.CREATE_USER = b.objuid\n" +
            "left join FAC_EMPLOYEE c on a.SHENPIREN = c.objuid \n" +
            "left join FAC_EMPLOYEE d on a.SHENQINGREN = d.objuid \n" +
            "left join FAC_EMPLOYEE e on a.xiuggairen = e.objuid \n" +
            "where 1=1 " +
            "<if test =\"o.createUserName !=null and o.createUserName != '' \">" +
            "   and b.EMP_NAME = #{o.createUserName, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.xiugairenName !=null and o.xiugairenName != '' \">" +
            "   and e.EMP_NAME = #{o.xiugairenName, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.tuhao !=null and o.tuhao != '' \">" +
            "   and a.tuhao like #{o.tuhao, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.jixing !=null and o.jixing != '' \">" +
            "   and a.jixing = #{o.jixing, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.state !=null \">" +
            "   and a.state = #{o.state, jdbcType=INTEGER} " +
            "</if>" +
            "order by a.xiuggaishijian desc " +
            "</script>")
    List<FenguangYingduRecordLogQueryDO> selectPageList(@Param("o") FenguangYingduRecordLogQueryDO fenguangYingduRecordLogQueryDO, Page<FenguangYingduRecordLogQueryDO> page);
}
